#ifndef __CHANNEL_HPP__
#define __CHANNEL_HPP__

#include <iostream>
#include <string>
#include <unistd.h>

//先描述
class Channel 
{
public:
  Channel(int wfd, pid_t who) : _wfd(wfd), _who(who) {
    // Channel-3-1314
    _name = "Channel-" + std::to_string(wfd) + "-" + std::to_string(who);
  }
  //返回传输信息
  std::string Name() { return _name; }
  //发送任务
  void Send(int command) { ::write(_wfd, &command, sizeof(command)); }

  //退出进程池
  void Close() { ::close(_wfd); }
  pid_t Id() { return _who; }
  ~Channel() {}

private:
  int _wfd;
  std::string _name;
  pid_t _who;
};

#endif